/*
 * @Author: QinJiu
 * @Date: 2022-07-20 10:36:04
 * @LastEditors: Qinjiu
 * @LastEditTime: 2022-07-20 14:06:55
 * @Description:
 */
import Mock from "mockjs";

// 获取 mock.Random 对象

const Random = Mock.Random;

const userInfo = {
  userName: "小明同学",
  age: 18,
  roles: ["admin"], // 权限信息
};

// 登录
Mock.mock("/mock/user/login", "post", function (req, res) {
  return {
    code: 200,
    msg: "登录成功",
    data: {
      token: "token12345",
      userInfo,
    },
  };
});

// 获取用户信息
Mock.mock("/mock/user/info", "get", function () {
  return {
    code: 200,
    msg: "查询用户信息成功",
    data: {
      userInfo,
    },
  };
});

// 获取用户信息
Mock.mock("/mock/user/logout", "post", function () {
  return {
    code: 200,
    msg: "登出成功",
    data: {},
  };
});

Mock.mock("/mock/longdata", "get", function () {
  const result = [];
  for (var i = 0; i < 250; i++) {
    let obj = {
      uid: Random.id(),
      title: Random.csentence(5, 28), // 随机的标题
      city: Random.city(), // 随机的城市
      names: Random.cname(), // 名字
      pic: Random.image("200x100", "#02adea", "wuhan2010"),
      time: Random.date("yyyy-MM-dd") + " " + Random.time(),
    };
    result.push(obj);
  }
  return {
    type: 1,
    code: 200,
    msg: "获取数据成功",
    result,
  };
});
